<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/include/header.jsp"%>
</head>
<body>
	<div class="wrap">
		<!-- top start -->
		<%@ include file="/include/top.jsp"%>
		<!-- top end -->

		<div class="main">
			<!--left start-->
			<%@ include file="/include/left.jsp"%>
			<!--left end-->

			<!--right start-->
			<div class="m_right">
				<div class="switch" id="switch"></div>
				<div class="p_bar">您当前的位置：${config.beanDescription}列表</div>
				<div class="con_box">				
					<form id="searchForm">
						<input type="hidden" id="CSRFToken" name="CSRFToken" value="<hna:csrfToken />" />				
						<table class="c_table m_t10">
							<tr>
								<td> ：<input type="text" name="" class="input_txt" /></td>
								<td> 操作时间：<input type="text" name="startTime" class="input_txt Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 100px" />&nbsp;至&nbsp;<input type="text" name="endTime" class="input_txt Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 100px" /></td>								
								<td>
									<input type="button" id="searchBtn" value="查询" class="c_btn"> 
								</td>
							</tr>
						</table> 
					</form>
				</div>				
				<div class="action_box m_t10 t_r pro_box">
					<input type="button" class="r_btn" value="添加" id="addBtn" />
					<table id="list_wrap" class="table_list m_t10"></table>
					<div class="page eui-pager-custom" id="list_pager"></div>
				</div>
			</div>
			<!--right end-->
		</div>
		<div class="bottom_box"></div>
	</div>
	
<script type="text/html" id="list_template">
		<thead>
				<tr>
<#list columnList as column>
					<th>${column.dbColumnComment}</th>
</#list>
					<th>操作</th>
				</tr>
		</thead>
		<tbody data-type="body">
			<!if(list.length>0) { !>
				<!for(var i=0,len=list.length;i<len;i++){
					var item = list[i],classItem = (i%2!=0)?"odd td_odd":"even";
				!>
				<tr class="gradeA <!=classItem!>">
					<#list columnList as column>
						<td title="<!=item["${column.javaPropertyName}"]!>"><!=item["${column.javaPropertyName}"]!></td>
					</#list>
						<td>
							<input type="button"  data-id="<!=item["${columnList[0].javaPropertyName}"]!>"  value="详情" class="btn_view m_r5" action="view">
							<input type="button"  data-id="<!=item["${columnList[0].javaPropertyName}"]!>"  value="修改" class="btn_edit m_r5" action="edit">
							<input type="button"  data-id="<!=item["${columnList[0].javaPropertyName}"]!>"  value="删除" class="btn_delete m_r5" action="delete">
						</td>
				</tr>
			<!}!>
			<!}else{!>
				<tr>
					<td colspan="${columnList?size+1}"> 暂无数据</td>
				</tr>
			<!}!>
		</tbody>
	</script>


	<script type="text/javascript">
		$(function() {
			// 添加
			$("#addBtn").on("click", function() {
				layer.open({
				    type: 2,
				    title: "添加${config.beanDescription}",
				    area: ["800px", "450px"],
				    content: "${ctx}/${simpleBeanName}/toAdd.do"
				  });
			});			
			
			// 详细
			$("#list_wrap").on("click", "[action='view']", function() {
				var ${beanId} = $(this).data("id");
				layer.open({
				    type: 2,
				    title: "查看${config.beanDescription}详细信息",
				    area: ["800px", "450px"],
				    content: "${ctx}/${simpleBeanName}/view.do?${beanId}=" + ${beanId}
				  });
			});	
					
			
			// 编辑
			$("#list_wrap").on("click", "[action='edit']", function() {
				var ${beanId} = $(this).data("id");
				layer.open({
				    type: 2,
				    title: "编辑${config.beanDescription}详细信息",
				    area: ["800px", "450px"],
				    content: "${ctx}/${simpleBeanName}/toEdit.do?${beanId}=" + ${beanId}
				  });				
			});	
					
			// 删除
			$("#list_wrap").on("click", "[action='delete']", function() {
				var ${beanId} = $(this).data("id");
				if (confirm('确定删除？')) {
					sysUtil.postJosn("${ctx}/${simpleBeanName}/delete.do", {${beanId} :${beanId},CSRFToken:$("#CSRFToken").val()}, function(result) {
						if(result.isSucc){
							search();
							alert("操作成功!");
						}else{
							alert(result.warnMsg);
						}					
					});				
				}
			});

			// 查询
			$("#searchBtn").on("click", function() {
				search({initPage:1});
			});	
			
			// 页面加载完成调用查询分页
			search();
		});
		
		//查询
		function search(coverOption) {
			var option={
					url:"${ctx}/${simpleBeanName}/ajaxPage.do",
					params:$("#searchForm").serializeJson()
			};
			$.extend(option, coverOption);
			sysUtil.page(option);
		}		
	</script>
	<%@ include file="/include/footer.jsp"%>
</body>
</html>
